package com.example.wsdemo.axis;

import org.apache.axis.EngineConfigurationFactory;
import org.apache.axis.transport.http.AxisServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;



@Configuration
public class AxisConfig {
    @Bean
    public ServletRegistrationBean axisServletRegistrationBean() {
        //想要以jar包形式发布，所以需要重写EngineConfigurationFactory类，否则会访问不到。新建org.apache.axis.configuration.EngineConfigurationFactoryServlet，继承EngineConfigurationFactoryDefault。更改的是getServerEngineConfig(ServletConfig cfg)方法。（注意：该类需要放在org.apache.axis.configuration包下，我尝试放在其他路径下无效
        //com.example.wsdemo.axis.EngineConfigurationFactory 改为 axis.EngineConfigFactory
        System.setProperty(EngineConfigurationFactory.SYSTEM_PROPERTY_NAME, com.example.wsdemo.axis.EngineConfigurationFactory.class.getName());
        AxisServlet servlet = new AxisServlet();
        ServletRegistrationBean servletBean = new ServletRegistrationBean(servlet, "/axis/*", "/services/*");
        servletBean.setLoadOnStartup(1);
        return servletBean;
    }
}

